<template>
    <!-- 权限分配页面 -->
    <div class="per">
        <navall />
        <pageheader />

        <div class="perr">
            <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
            <!-- <div style="margin: 15px 0;"></div> -->
            <el-checkbox-group v-model="checkedCities" @change="handleCheckedCitiesChange">
              <el-checkbox v-for="city in cities" :label="city" :key="city">{{city}}</el-checkbox>
            </el-checkbox-group>
            <el-checkbox :indeterminate="isIndeterminate" v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
        </div>
        
    </div>
</template>

<script>
import navall from '@/components/navall.vue'
import pageheader from '@/components/pageheader.vue'

const cityOptions = ['上海', '北京', '广州', '深圳','杭州','山东','武汉','天津','哈尔滨','云南','四川','西安','长沙','南昌','成都'];
export default {
  data() {
    return {
      checkAll: false,
      checkedCities: ['上海', '北京','杭州'],
      cities: cityOptions,
      isIndeterminate: true
    };
  },
  components:{
    navall,
    pageheader,
  },
  methods: {
    handleCheckAllChange(val) {
      this.checkedCities = val ? cityOptions : [];
      this.isIndeterminate = false;
    },
    handleCheckedCitiesChange(value) {
      let checkedCount = value.length;
      this.checkAll = checkedCount === this.cities.length;
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.cities.length;
    }
  }
}
</script>

<style lang="css" scoped>
div.el-checkbox {
    margin: 0 auto!important;
}
div.el-checkbox-group {
    display: inline-block;
    width: 70%!important;
    /* text-align: left; */
}
.perr {
  margin-left: 5%;
  width: 100%;
}
</style>